package com.doubi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.doubi.entity.Commenttable;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CommenttableMapper extends BaseMapper<Commenttable> {
    @Select("select * from commenttable order by cid desc limit 0,1")
    public Commenttable getLastComment();

    //查询视频总评论数
    @Select("select COUNT(*) from commenttable where releaseId=#{rid}")
    public int countByRid(int rid);

    public List<Commenttable> getCommentByRid(@Param("rid") List<Integer> rid);

    //删除评论方法
    public int updateComment(@Param("cid") List<Integer> cid);
    /**
     * 总评论数
     */
    @Select("select COUNT(*) from commenttable where releaseId=#{releaseId}")
    Integer getLastCommentCount(@Param("releaseId") Integer releaseId);

    /**
     * 点赞评论
     */
    @Update("update commenttable set likeCounts=#{commenttable.likeCounts} where cid=#{commenttable.cid}")
    public Integer updateLikeComment(@Param("commenttable") Commenttable commenttable);
}
